#! /bin/sh

# wifi
WIFI=$(cat /sys/class/net/wlp2s0/operstate)
if [ $WIFI = "up" ]; then
    WIFI="wifi"
else
    WIFI="wifi."
fi

# volume
TMP=$(amixer get Master | tail -n1)
VOL=${TMP#*[}
VOL=${VOL%%]*}
if [[ $TMP =~ off ]]; then
    VOL="vol.$VOL"
else
    VOL="vol/$VOL"
fi

# battery
TMP=$(acpi -b)
BAT=${TMP#* * * }
BAT=${BAT%%, *}
if [[ $TMP =~ Charging ]]; then
    BAT="bat^$BAT"
else
    BAT="bat/$BAT"
fi

# time
TIME=$(date +"%m/%d %R")

xsetroot -name "$* $WIFI $VOL $BAT $TIME"
